/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Artifacts;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.EnumerationProperty;
import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Kernel.Operation;
import edu.pku.sei.modeler.model.uml.Kernel.Property;

import edu.pku.sei.modeler.model.uml.Kernel.Classifier;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Artifact extends Classifier implements IArtifact {
	// attributes
	
	protected String fileName;
	
	
	
	
	// references
	
	protected MetaTypedList manifestation;
	
	protected MetaTypedList nestedArtifact;
	
	protected MetaTypedList ownedOperation;
	
	protected MetaTypedList ownedAttribute;
	
	
	//constructor
	public Artifact(){
		this.fileName = "unnamed file";
		this.name = fileName;
	}
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "ARTIFACT_FILENAME",
			catalog = "Model",
			name = ModelPackage.ARTIFACT_FILENAME,
			setter = "setFileName"
			)
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String newFileName) {
		String oldfileName = fileName;
		fileName = newFileName;
		firePropertyChange(ModelPackage.ARTIFACT_FILENAME, oldfileName, newFileName);
	}
	
	// getters for references
	
	public MetaTypedList getManifestation() {
		if(manifestation == null) {
			manifestation = new MetaTypedList(Manifestation.class, this, ModelPackage.ARTIFACT_MANIFESTATION);
		}
		return manifestation;
	}
	
	public MetaTypedList getNestedArtifact() {
		if(nestedArtifact == null) {
			nestedArtifact = new MetaTypedList(Artifact.class, this, ModelPackage.ARTIFACT_NESTEDARTIFACT);
		}
		return nestedArtifact;
	}
	
	public MetaTypedList getOwnedOperation() {
		if(ownedOperation == null) {
			ownedOperation = new MetaTypedList(Operation.class, this, ModelPackage.ARTIFACT_OWNEDOPERATION);
		}
		return ownedOperation;
	}
	
	public MetaTypedList getOwnedAttribute() {
		if(ownedAttribute == null) {
			ownedAttribute = new MetaTypedList(Property.class, this, ModelPackage.ARTIFACT_OWNEDATTRIBUTE);
		}
		return ownedAttribute;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.ARTIFACT_FILENAME, fileName);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ARTIFACT_MANIFESTATION, manifestation);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ARTIFACT_NESTEDARTIFACT, nestedArtifact);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ARTIFACT_OWNEDOPERATION, ownedOperation);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ARTIFACT_OWNEDATTRIBUTE, ownedAttribute);
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		fileName = XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.ARTIFACT_FILENAME);
		
		// references
		
		this.getManifestation().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ARTIFACT_MANIFESTATION));
		
		this.getNestedArtifact().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ARTIFACT_NESTEDARTIFACT));
		
		this.getOwnedOperation().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ARTIFACT_OWNEDOPERATION));
		
		this.getOwnedAttribute().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ARTIFACT_OWNEDATTRIBUTE));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 